/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package publicapplication;

import java.io.*;

/**
 *
 * @author houfukude
 */
public class main {
    
    public static void main(String[] args) {
        boolean continue_e = true;
        while(continue_e){
            try{// 系统提示 用户选择
                System.out.println("\n请选择你要进行的操作(请输入1-4中人一个数字);\n" 
                        + "1:输入书的信息;\n" 
                        + "2:输入CD的信息;\n" 
                        + "3:输入磁带的信息;\n" 
                        + "4:退出系统;\n");
                // 读取输入流信息
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                int choice = Integer.valueOf(br.readLine()).intValue();
                // 强制转换成int型
                switch (choice) {
                    case 1:{
                        chooseAbook();// 选择为书
                    
                    break;
                    } 
                    case 2:{
                        chooseAcd();// 选择为CD
                    
                    break;
                    } 
                    case 3:{
                        chooseAtape();// 选择为磁带
                    
                    break;
                    } 
                    case 4:{
                        continue_e = false;// 选择退出系统
                        break;
                    }
                    default: inputError();
                        // 选择错误
                }
            } catch (IOException ex1) {

            } catch (NumberFormatException ex2){// 如果无法强制转化成INt说明输入错误
            inputError();
            }
        }
        System.out.println("你已经正常退出\n欢迎下次使用!");
            
        


    }

    private static void chooseAbook() throws IOException {// 输入书的名称，价格等信息的输入相关信息，然后程序输出这些信息
        MyBook book = new MyBook();
        // 实现所有的book的方法
        book.mediaNameInput();
        book.mediaPriceInput();
        book.mediaPressInput();
        book.artistInput();
        book.ISBNInput();
        book.editorInput();
        book.publishDateInput();
        // 输出 输入的信息
        System.out.println("\n the book name   :"+ book.mediaName
                +"\n the book price  :" + book.price
                +"\n the book press  :" + book.press
                +"\n the book artist :" + book.artist
                +"\n the book ISBN   :" + book.ISBN
                +"\n the book editor :" + book.editor
                +"\n the book pubDate:" + book.publishDate);
    }

    private static void chooseAcd() throws IOException {// 输入CD的名称，价格等信息的输入相关信息，然后程序输出这些信息
        MyCD cd = new MyCD();
        // 实现所有CD的方法
        cd.mediaNameInput();
        cd.mediaPriceInput();
        cd.mediaPressInput();
        cd.artistInput();
        cd.ISBNInput();
        cd.cdPublisher();
        // 输出CD信息
        System.out.println("\n the CD name     :" + cd.mediaName
                +"\n the CD price    :" + cd.price
                +"\n the CD press    :" + cd.press
                +"\n the CD artist   :" + cd.artist
                +"\n the CD ISRC     :" + cd.ISRC
                +"\n the CD publisher:" + cd.cdPublisher);
        
    }

    private static void chooseAtape() throws IOException {// 输入磁带的名称，价格等信息的输入相关信息，然后程序输出这些信息
        MyTape tape = new MyTape();
        // 实现所有tape的方法
        tape.mediaNameInput();
        tape.mediaPriceInput();
        tape.mediaPressInput();
        tape.artistInput();
        tape.ISBNInput();

        System.out.println("\n the tape name     :" + tape.mediaName
                +"\n the tape price    :" + tape.price
                +"\n the tape press    :" + tape.press
                +"\n the tape artist   :" + tape.artist
                +"\n the tape ISRC     :" + tape.ISRC);
        
    }

    private static void inputError() {// 当出现输入错误的方法
        System.out.println("input error;\n input again!");
        
        
    }
}
